<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="layui/css/layui.css">
<script src="layui/layui.js"></script>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$(function(){
	$("#name").blur(function(){
		var Name=$("input#name").val();
		var myFunction = function(api){
			//alert(result);
			if(api.status==1){
				if(api.data==-1){
					$("#first").html("此用户不存在");
				}else{
					$("#first").html("此用户存在");
				}
			}else{
				alert("失败");
			}
		};
		$.ajax({
			url:"IfUser",
			type:'GET',
			data:{name:Name},
			dataType:'json',
			success:myFunction,
			timeout:3000
		});
	});
	
});
</script>
</head>
<body>
	<font size="36"  face="微软雅黑">&nbsp; &nbsp;欢迎登录</font>
	<form class="layui-form" action="LandingAction" method="post">
	<div class="layui-form-item">
		<label class="layui-form-label">用户名:</label>
		<div class="layui-input-inline">
			<input id="name" type="text" name="uName" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
		</div>
		<div id="first" style="font-size:18px"></div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">密码:</label>
		<div class="layui-input-inline">
			<input type="password" name="uPassword" required lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button type="submit" class="layui-btn" layui-submit lay-filter="forDemo">登陆</button>
			<button type="reset" class="layui-btn" layui-btn-primary lay-filter="forDemo">重置</button>
		</div>
	</div>
</form>
</body>
<script>
//Demo
layui.use('form', function(){
  var form = layui.form();
  
  //监听提交
  form.on('submit(formDemo)', function(data){
    layer.msg(JSON.stringify(data.field));
    return false;
  });
});
</script>
</html>